<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<script type="text/javascript"
        src="<%=request.getContextPath()%>/script/includedialog.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/script/questionnaire/main.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/script/includedialog.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#previewBtn").click(function () {
            pov(${param.id});
        });
    });
</script>

<jsp:include page="menu.jsp" />

<!--START: Subnav -->
<div class="sub_nav">
    <ul>
        <li>
            <a href="view.html?id=${dialog.questionnaireId}"><img
                    src="<%=request.getContextPath()%>/images/menu/sub_general_off.gif"
                width="114" height="18" alt="gernal" /> </a>
        </li>
        <li>
            <a href="#"><img
                    src="<%=request.getContextPath()%>/images/menu/sub_pages_on.gif"
                width="114" height="18" alt="page" /> </a>
        </li>
    </ul>
</div>
<!--END: Subnav -->

<!--START: conent -->
<div class="content2">
    <div class="insider">
        <div class="corners">
            <div class="corners_top"></div>

            <jsp:include page="baseInfo.jsp" />

            <ul class="functions1 fun1_3">
                <li>

                    <a href="list.html?checkSearch=list">
                        <img width="122" height="23" class="btn" src="<%= request.getContextPath()%>/images/btn/functions1/back_to_results.gif"/>
                    </a>

                </li>
                <security:authorize ifAnyGranted="ROLE_PORTAL_USER, ROLE_AUTHOR">
                    <c:if test="${dialog.publicationStatus.code=='inprocess'}">
                        <li><a href="edit.html?id=${dialog.questionnaireId}" id="editdialog"><img src="<%= request.getContextPath()%>/images/btn/functions1/btn_edit.gif" width="122" height="23" class="btn" /></a></li>
                    </c:if>
                    <c:if test="${dialog.publicationStatus.code!='inprocess'}">
                        <li><a href="#"><img src="<%= request.getContextPath()%>/images/btn/functions1/btn_edit_tint.gif" width="122" height="23"/></a></li>
                    </c:if>
                    <li>
                        <a href="#" id="previewBtn">
                            <img src="<%= request.getContextPath()%>/images/btn/functions1/btn_preview.gif"
                                 class="btn" />
                        </a>
                    </li>
                </security:authorize>

            </ul>
            <div class="corners_bottom"></div>
        </div>

        <div class="error">
            <h3 id="pagemessage">
                ${pagemessage}
                <style> p { margin:0px }</style>
                <font color="red">
                    <p id="Msg_Retire" style="display:none;">${Msg_Retire_Dialog}</p>
                    <p id="Msg_Locked" style="display:none">${Msg_Locked}</p>
                </font>
            </h3>
        </div>

        <ul class="functions2">
            <li class="view">
                <a href="#" onclick="clickAction('../questionset/view')">
                    <img name="qbtn" class="btn" src="<%= request.getContextPath()%>/images/btn/functions2/btn_view_light.gif" alt="view" />
                </a>
            </li>
            <security:authorize ifAnyGranted="ROLE_PORTAL_USER, ROLE_AUTHOR">
                <li>
                    <a href="#" onclick="blinkAction('../questionset/edit')">
                        <img name="qbtn" class="btn" src="<%= request.getContextPath()%>/images/btn/functions2/btn_edit_light.gif" alt="edit" id ="editButton"/>
                    </a>
                </li>
            </security:authorize>
        </ul>

        <table width="100%" cellspacing="0" class="data_thead">
            <thead>
            <tr>
                <th width="5%"></th>
                <th width="15%">Name</th>
                <th width="12%">ID</th>
                <th width="8%">Version</th>
                <th width="16%">Status/Availability
                </th>
                <th width="44%">
                    Title
                </th>
            </tr>
            <thead>
        </table>
        <div class="question_sets">
            <div class="question_sets_inside">

                <div class="question">
                    <c:forEach var="qis" items="${pages}" varStatus="pageindex">
                        <table width="100%" border="0" cellpadding="0" cellspacing="0"
                               onclick="itemClick(this, 'id=${qis.questionSet.questionSetId}','${qis.questionSet.availability.code}', '${qis.questionSet.status.code}');">
                            <tbody>
                                <tr>
                                    <th width="5%" class="number0">${pageindex.index+1}</th>
                                    <td width="15%" class="row1">${qis.questionSet.name}</td>
                                    <td width="18%" class="row2">${qis.questionSet.refId}</td>
                                    <td width="8%" class="row2">Ver ${qis.questionSet.version}</td>
                                    <td width="16%" class="row3">
                                        ${qis.questionSet.availability.name}
                                        /
                                        ${qis.questionSet.status.name}
                                    </td>
                                    <td width="31%" class="row4">
                                        ${qis.questionSet.listdisplayTitle}
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </c:forEach>
                </div>
            </div>
        </div>
    </div>
</div>
<!--END: conent -->

<jsp:include page="previewFrame.jsp" />